home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / util2 / vol12n11.zip / OLFONT.ZIP / OLFCLIP.C < prev    next >
C/C++ Source or Header  |  1993-04-04  |  2KB  |  74 lines

  1. /*-----------------------------------------
  2.    OLFCLIP.C -- OS/2 Outline Font Clipping
  3.                 (c) Charles Petzold, 1993
  4.   -----------------------------------------*/
  5.  
  6. #define INCL_WIN
  7. #define INCL_GPI
  8. #include <os2.h>
  9. #include <string.h>
  10. #include "olf.h"
  11.  
  12. #define LCID_FONT    1
  13.  
  14. void PaintClient (HPS hps, SHORT cxClient, SHORT cyClient)
  15.      {
  16.      static CHAR szText [] = "Hello!" ;
  17.      int         i ;
  18.      POINTL      ptl, aptl[3], aptlTextBox [TXTBOX_COUNT] ;
  19.  
  20.           // Create and size the logical font
  21.  
  22.      CreateOutlineFont (hps, LCID_FONT, "Times New Roman Italic", 0, 0) ;
  23.      GpiSetCharSet (hps, LCID_FONT) ;
  24.      ScaleOutlineFont (hps, 1440, 1440) ;
  25.  
  26.           // Get the text box
  27.  
  28.      GpiQueryTextBox (hps, strlen (szText), szText,
  29.                       TXTBOX_COUNT, aptlTextBox) ;
  30.  
  31.           // Create the path
  32.  
  33.      GpiBeginPath (hps, 1) ;
  34.  
  35.      ptl.x = (cxClient - aptlTextBox [TXTBOX_CONCAT].x) / 2 ;
  36.      ptl.y = (cyClient - aptlTextBox [TXTBOX_TOPLEFT].y
  37.                        - aptlTextBox [TXTBOX_BOTTOMLEFT].y) / 2 ;
  38.  
  39.      GpiCharStringAt (hps, &ptl, strlen (szText), szText) ;
  40.  
  41.      GpiEndPath (hps) ;
  42.  
  43.           // Set the clipping path
  44.  
  45.      GpiSetClipPath (hps, 1, SCP_AND | SCP_ALTERNATE) ;
  46.  
  47.           // Draw Bezier splines
  48.  
  49.      for (i = 0 ; i < cyClient ; i++)
  50.           {
  51.           GpiSetColor (hps, (i / 16) % 6 + 1) ;
  52.  
  53.           ptl.x = 0 ;
  54.           ptl.y = i ;
  55.           GpiMove (hps, &ptl) ;
  56.  
  57.           aptl[0].x = cxClient / 3 ;
  58.           aptl[0].y = i + cyClient / 3 ;
  59.  
  60.           aptl[1].x = 2 * cxClient / 3 ;
  61.           aptl[1].y = i - cyClient / 3 ;
  62.  
  63.           aptl[2].x = cxClient ;
  64.           aptl[2].y = i ;
  65.  
  66.           GpiPolySpline (hps, 3, aptl) ;
  67.           }
  68.  
  69.           // Select the default font; delete the logical font
  70.  
  71.      GpiSetCharSet (hps, LCID_DEFAULT) ;
  72.      GpiDeleteSetId (hps, LCID_FONT) ;
  73.      }
  74.